package main

import (
	"os"
	"fmt"
	"bufio"
	"io"
)

func main(){
	filePath1 := "../1.txt"
	filePath2 := "../2.txt"
	file1,err1 := os.Open(filePath1)
	file2,err2 := os.OpenFile(filePath2,os.O_WRONLY|os.O_TRUNC,0666)
	defer file1.Close()
	defer file2.Close()
	if err1 != nil {
		fmt.Println(err1)
	}
	if err2 != nil {
		fmt.Println(err2)
	}
	reader := bufio.NewReader(file1)
	writer := bufio.NewWriter(file2)
	for {
		line,err3 := reader.ReadString('\n')
		fmt.Print(line)
		n,_ := writer.WriteString(line)
		if err3 == io.EOF{
			fmt.Println(n)
			break
		}
	}
	writer.Flush()
}
